using ASP;
using HoWave.Common;
using HoWave.Web;
using HoWave.Web.Shop.Member;
using System;
using System.Data;
using System.Web;
using System.Web.Profile;
using System.Web.SessionState;
using System.Web.UI.WebControls;
namespace tenpay
{
	public class index : Member, IRequiresSessionState
	{
		protected Label TxtOrderno;
		protected Label TxtPrice;
		protected Label TxtQua;
		protected Label TxtSubject;
		protected Label TxtBody;
		protected Label Label1;
		protected Label TxtPost;
		protected Label lblPartentID;
		protected Label lblKey;
		protected Label lblURL;
		public static string OrderFormNum = "";
		public DataTable DTOrder;
		protected static DataRow Payconfig = new Config().config;
		protected DefaultProfile Profile
		{
			get
			{
				return (DefaultProfile)this.Context.Profile;
			}
		}
		protected global_asax ApplicationInstance
		{
			get
			{
				return (global_asax)this.Context.ApplicationInstance;
			}
		}
		protected void Page_Load(object sender, EventArgs e)
		{
			index.OrderFormNum = Fetch.Get("OrderFormNum");
			if (index.OrderFormNum == string.Empty)
			{
				this.WriteErrMsg("", Language.Get("Common/LostParam", "OrderFormNum"), "");
			}
			Shop_Order shop_Order = new Shop_Order(this.conn);
			this.DTOrder = shop_Order.GetTenPayByOrderFormNum(index.OrderFormNum);
			if (this.DTOrder.Rows.Count <= 0)
			{
				this.WriteErrMsg("", Language.Get("Common/NotData"), "");
				HttpContext.Current.Response.Redirect("Error.aspx");
			}
			this.TxtOrderno.Text = this.DTOrder.Rows[0]["OrderFormNum"].ToString();
			this.TxtPrice.Text = this.DTOrder.Rows[0]["MoneyTotal"].ToString();
			this.TxtQua.Text = this.DTOrder.Rows[0]["Quantity"].ToString();
			string text = this.DTOrder.Rows[0]["ProductName"].ToString();
			if (text.Length > 25)
			{
				this.TxtSubject.Text = text.Substring(0, 25);
			}
			else
			{
				this.TxtSubject.Text = text;
			}
			if (this.DTOrder.Rows[0]["Remark"].ToString() == "")
			{
				this.TxtBody.Text = "价格不贵，质量又好,快来抢购哦!";
			}
			else
			{
				this.TxtBody.Text = this.DTOrder.Rows[0]["Remark"].ToString();
			}
			if (this.DTOrder.Rows[0]["DeliverTypeName"].ToString() == "")
			{
				this.Label1.Text = "平邮";
			}
			else
			{
				this.Label1.Text = this.DTOrder.Rows[0]["DeliverTypeName"].ToString();
			}
			this.TxtPost.Text = this.DTOrder.Rows[0]["Deliver_TotalPrice"].ToString();
			this.lblPartentID.Text = this.DTOrder.Rows[0]["BussinessCount"].ToString();
			this.lblKey.Text = this.DTOrder.Rows[0]["BussinesMD5Key"].ToString();
			decimal num = decimal.Parse(this.TxtPrice.Text) * 100m;
			string text2 = this.DTOrder.Rows[0]["BussinessCount"].ToString();
			string key = this.DTOrder.Rows[0]["BussinesMD5Key"].ToString();
			string str = DateTime.Now.ToString("yyyyMMdd");
			string str2 = DateTime.Now.ToString("HHmmss") + TtenpayUtil.BuildRandomStr(4);
			string orderFormNum = index.OrderFormNum;
			string parameterValue = text2 + str + str2;
			string str3 = index.Payconfig["SiteUrl"].ToString().Contains("http://") ? index.Payconfig["SiteUrl"].ToString() : ("http://" + index.Payconfig["SiteUrl"].ToString());
			string parameterValue2 = str3 + "PayReturn/TenpayApp/return_url.aspx";
			PayRequestHandler payRequestHandler = new PayRequestHandler(this.Context);
			payRequestHandler.setKey(key);
			payRequestHandler.init();
			payRequestHandler.setParameter("bargainor_id", text2);
			payRequestHandler.setParameter("sp_billno", orderFormNum);
			payRequestHandler.setParameter("transaction_id", parameterValue);
			payRequestHandler.setParameter("return_url", parameterValue2);
			payRequestHandler.setParameter("desc", "订单号：" + orderFormNum);
			payRequestHandler.setParameter("total_fee", num.ToString().Replace(".00", ""));
			string requestURL = payRequestHandler.getRequestURL();
			string text3 = "<a target=\"_blank\" href=\"" + requestURL + "\">确认支付</a>";
			this.lblURL.Text = text3;
		}
		protected override void OnInit(EventArgs e)
		{
			this.InitializeComponent();
			base.OnInit(e);
		}
		private void InitializeComponent()
		{
		}
	}
}
